package com.homework;

import java.util.Objects;

/**
 * 描述: 饮料类
 *
 * @author CodeYang
 * @version 2020/12/17 10:09
 */
public class Drink {

    private  String name;
    /**
     * 容量
     */
    private double capacity;

    public Drink() {
    }

    public Drink(String name, double capacity) {
        this.name = name;
        this.capacity = capacity;
    }
    public  void show(){
        System.out.println("您购买的饮料信息如下:");
        System.out.println("名称:"+name);
        System.out.println("容量:"+capacity);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getCapacity() {
        return capacity;
    }

    public void setCapacity(double capacity) {
        this.capacity = capacity;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Drink drink = (Drink) o;
        return Double.compare(drink.capacity, capacity) == 0 &&
                name.equals(drink.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, capacity);
    }
}
